import unittest
from atomicinteger import AtomicInteger

class TestAtomicInt(unittest.TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass
    
    def testAtomic(self):
        atom = AtomicInteger(5)
        self.assertEqual(5, atom.get())
        value = atom.getAndSet(3)
        self.assertEqual(5, value)
        self.assertEqual(3, atom.get())
        value = atom.getAndIncrement()
        self.assertEqual(3, value)
        self.assertEqual(4, atom.get())
        value = atom.getAndDecrement()
        self.assertEqual(4, value)
        self.assertEqual(3, atom.get())
        value = atom.incrementAndGet()
        self.assertEqual(4, value)
        self.assertEqual(4, atom.get())
        value = atom.decrementAndGet()
        self.assertEqual(3, value)
        self.assertEqual(3, atom.get())
        
    
suite = unittest.TestLoader().loadTestsFromTestCase(TestAtomicInt)
if __name__ == '__main__':
    unittest.TextTestRunner(verbosity=2).run(suite)